﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Liwey.Common;

namespace Liwey.SGCC
{
    public partial class ChangeBalanceDlg : Form
    {
        private Config.Park selectedCourse;
        public Config.Park SelectedCourse
        {
            get { return selectedCourse; }
            set { 
                selectedCourse = value;
                label3.Text = selectedCourse.name;
                textBox1.Text = selectedCourse.balance.ToString();
            }
        }

        public ChangeBalanceDlg()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                int b = int.Parse(textBox1.Text);

                if (b < 0 || b > selectedCourse.places)
                {
                    Msg.Error("车位数无效。");
                    return;
                }
                selectedCourse.balance = b;
                DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                Msg.Error(ex.Message);
            }
        }
    }
}
